<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false"
  CodeFile="Vendors.aspx.vb" Inherits="Vendors" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
  <asp:SqlDataSource ID="sqlVendors" runat="server" ConnectionString="<%$ ConnectionStrings:VendorStatsConnectionString %>"
    DeleteCommand="DELETE FROM [Vendors] WHERE [VendorId] = @VendorId"
    InsertCommand="INSERT INTO [Vendors] ([Name], [CounterCompliant], [DisplayName], [Username], [Password], [Scraper], [Option1], [Option2]) VALUES (@Name, @CounterCompliant, @DisplayName, @Username, @Password, @Scraper, @Option1, @Option2)"
    SelectCommand="SELECT * FROM [Vendors] ORDER BY [Name]" 
    UpdateCommand="UPDATE [Vendors] SET [Name] = @Name, [CounterCompliant] = @CounterCompliant, [DisplayName] = @DisplayName, [Username] = @Username, [Password] = @Password, [Scraper] = @Scraper, [Option1] = @Option1, [Option2] = @Option2 WHERE [VendorId] = @VendorId">
    <DeleteParameters>
      <asp:Parameter Name="VendorId" Type="Int32" />
    </DeleteParameters>
    <UpdateParameters>
      <asp:Parameter Name="Name" Type="String" />
      <asp:Parameter Name="CounterCompliant" Type="Boolean" />
      <asp:Parameter Name="DisplayName" Type="String" />
      <asp:Parameter Name="Username" Type="String" />
      <asp:Parameter Name="Password" Type="String" />
      <asp:Parameter Name="Scraper" Type="String" />
      <asp:Parameter Name="Option1" Type="String" />
      <asp:Parameter Name="Option2" Type="String" />
      <asp:Parameter Name="VendorId" Type="Int32" />
    </UpdateParameters>
    <InsertParameters>
      <asp:Parameter Name="Name" Type="String" />
      <asp:Parameter Name="CounterCompliant" Type="Boolean" />
      <asp:Parameter Name="DisplayName" Type="String" />
      <asp:Parameter Name="Username" Type="String" />
      <asp:Parameter Name="Password" Type="String" />
      <asp:Parameter Name="Scraper" Type="String" />
      <asp:Parameter Name="Option1" Type="String" />
      <asp:Parameter Name="Option2" Type="String" />
    </InsertParameters>
  </asp:SqlDataSource>
  <br />

  <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="VendorId"
    DataSourceID="sqlVendors">
    <Columns>
      <asp:CommandField ShowEditButton="True" />
      <asp:BoundField DataField="VendorId" HeaderText="VendorId" InsertVisible="False"
        ReadOnly="True" SortExpression="VendorId" Visible="False" />
      <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
      <asp:CheckBoxField DataField="CounterCompliant" HeaderText="Counter Compliant" SortExpression="CounterCompliant">
        <HeaderStyle Width="20px" />
      </asp:CheckBoxField>
      <asp:BoundField DataField="DisplayName" HeaderText="Display Name" SortExpression="DisplayName" />
      <asp:BoundField DataField="Username" HeaderText="Username" SortExpression="Username" />
      <asp:BoundField DataField="Password" HeaderText="Password" SortExpression="Password" />
      <asp:BoundField DataField="Scraper" HeaderText="Scraper" SortExpression="Scraper" />
      <asp:BoundField DataField="Option1" HeaderText="Option 1" SortExpression="Option1" />
      <asp:BoundField DataField="Option2" HeaderText="Option 2" SortExpression="Option2" />
    </Columns>
  </asp:GridView>
  <br />
  <asp:FormView ID="FormView1" runat="server" DataKeyNames="VendorId" 
    DataSourceID="sqlVendors" DefaultMode="Insert" HeaderText="Add a new Vendor" 
    Width="428px">
    <EditItemTemplate>
      VendorId:
      <asp:Label ID="VendorIdLabel1" runat="server" Text='<%# Eval("VendorId") %>' />
      <br />
      Name:
      <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
      <br />
      CounterCompliant:
      <asp:CheckBox ID="CounterCompliantCheckBox" runat="server" 
        Checked='<%# Bind("CounterCompliant") %>' />
      <br />
      DisplayName:
      <asp:TextBox ID="DisplayNameTextBox" runat="server" 
        Text='<%# Bind("DisplayName") %>' />
      <br />
      Username:
      <asp:TextBox ID="UsernameTextBox" runat="server" 
        Text='<%# Bind("Username") %>' />
      <br />
      Password:
      <asp:TextBox ID="PasswordTextBox" runat="server" 
        Text='<%# Bind("Password") %>' />
      <br />
      Scraper:
      <asp:TextBox ID="ScraperTextBox" runat="server" Text='<%# Bind("Scraper") %>' />
      <br />
      Option 1:
      <asp:TextBox ID="Option1TextBox" runat="server" Text='<%# Bind("Option1") %>' />
      <br />
      Option 2:
      <asp:TextBox ID="Option2TextBox" runat="server" Text='<%# Bind("Option2") %>' />
      <br />
      <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
        CommandName="Update" Text="Update" />
      &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
        CausesValidation="False" CommandName="Cancel" Text="Cancel" />
    </EditItemTemplate>
    <InsertItemTemplate>
      Name:
      <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
      <br />
      CounterCompliant:
      <asp:CheckBox ID="CounterCompliantCheckBox" runat="server" 
        Checked='<%# Bind("CounterCompliant") %>' />
      <br />
      DisplayName:
      <asp:TextBox ID="DisplayNameTextBox" runat="server" 
        Text='<%# Bind("DisplayName") %>' />
      <br />
      Username:
      <asp:TextBox ID="UsernameTextBox" runat="server" 
        Text='<%# Bind("Username") %>' />
      <br />
      Password:
      <asp:TextBox ID="PasswordTextBox" runat="server" 
        Text='<%# Bind("Password") %>' />
      <br />
      Scraper:
      <asp:TextBox ID="ScraperTextBox" runat="server" Text='<%# Bind("Scraper") %>' />
      <br />
      <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
        CommandName="Insert" Text="Insert" />
      &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
        CausesValidation="False" CommandName="Cancel" Text="Cancel" />
    </InsertItemTemplate>
    <ItemTemplate>
      VendorId:
      <asp:Label ID="VendorIdLabel" runat="server" Text='<%# Eval("VendorId") %>' />
      <br />
      Name:
      <asp:Label ID="NameLabel" runat="server" Text='<%# Bind("Name") %>' />
      <br />
      CounterCompliant:
      <asp:CheckBox ID="CounterCompliantCheckBox" runat="server" 
        Checked='<%# Bind("CounterCompliant") %>' Enabled="false" />
      <br />
      DisplayName:
      <asp:Label ID="DisplayNameLabel" runat="server" 
        Text='<%# Bind("DisplayName") %>' />
      <br />
      Username:
      <asp:Label ID="UsernameLabel" runat="server" Text='<%# Bind("Username") %>' />
      <br />
      Password:
      <asp:Label ID="PasswordLabel" runat="server" Text='<%# Bind("Password") %>' />
      <br />
      Scraper:
      <asp:Label ID="ScraperLabel" runat="server" Text='<%# Bind("Scraper") %>' />
      <br />
      <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" 
        CommandName="Edit" Text="Edit" />
      &nbsp;<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" 
        CommandName="Delete" Text="Delete" />
      &nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
        CommandName="New" Text="New" />
    </ItemTemplate>
  </asp:FormView>
</asp:Content>
